// JavaScript Document

function puploadcompletehandler(){
	if(puploadid == "image"){
		var gc = puploadgc(puploadc);
		
		var c = '';
		c += '<div class="upfileline">';
		c += '<span class="right"><a href="javascript:void(0);" onclick="puploaddelete('+puploadc+')">X</a></span>';
		c += '<span class="left">'+gc[3]+'</span>';
		c += '</div>';
		
		$E("PUPF"+puploadid).innerHTML = "";
		$E("PUPP"+puploadid).innerHTML = c;
	} else if(puploadid == "pupfile"){
		//
		var gc = puploadgc(puploadc);
		var f = gc[0];
		var fe = f.substr(f.lastIndexOf(".")+1).toLowerCase();
		if( fe == "swf" ) {
			editor_insert_video(BASE_URL+"images/uploads/origins/"+f,300,300);
		} else if( fe == "flv" ) {
			editor_insert_video(BASE_URL+"video/mdplayer.swf?v="+f.substr(0,f.length-4),300,300);
		} else if( fe == "jpg" || fe == "jpeg" || fe == "gif" || fe == "png" || fe == "bmp" ) {
			editor_insert_image(BASE_URL+"images/uploads/resized/"+f,0,0,"attach_"+gc[5]);
		} else if( $E("upload_type_media").checked ) {
			editor_insert_media(BASE_URL+"images/uploads/thumbs/"+f,300,300);
		} else {
			editor_insert_resource(gc[3], BASE_URL+"images/uploads/origins/"+f);
		}
		//
		puploadreinit();
	} else {
		var gc = puploadgc(puploadc);
		var f = gc[0];
		var fe = f.substr(f.lastIndexOf(".")+1).toLowerCase();
		if(puploadparams['multi'] == 1){
			var c = '';
			c += '<div class="upfileline">';
			c += '<span class="right"><a href="javascript:void(0);" onclick="puploaddelete('+puploadc+')">X</a></span>';
			c += '<span class="left">'+gc[3]+'</span>';
			c += '</div>';
			
			//$E("PUPF").innerHTML = "";
			//$E("PUPP").innerHTML += c;
			//
			puploadreinit();
		} else {
			var c = '';
			c += '<div class="upfileline">';
			c += '<span class="right"><a href="javascript:void(0);" onclick="puploaddelete('+puploadc+')">X</a></span>';
			c += '<span class="left">'+gc[3]+'</span>';
			c += '</div>';
			
			//$E("PUPF").innerHTML = "";
			//$E("PUPP").innerHTML = c;
			if( fe == "jpg" || fe == "jpeg" || fe == "gif" || fe == "png" || fe == "bmp" ) {
				//
			} else {
				$E("PUPP"+puploadid).innerHTML = c;
			}
			//
			puploadreinit();
		}
	}
}
function puploaddeletehandler(){
	var p = puploadid;
	puploadparams = puploadps(puploadpss[p]);
	puploadc++;
	if($E("PUPF"+puploadid)){
		$E("PUPF"+puploadid).innerHTML = puploadf();
		$E("PUPH"+puploadid).innerHTML = puploadh();
		$E("PUPP"+puploadid).innerHTML = "";
	}
}
